package com.sunwayworld.basemodule.rm.hospital.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.rm.hospital.dao.LimsInterfaceSourceDao;
import com.sunwayworld.basemodule.rm.hospital.bean.LimsInterfaceSourceBean;
import com.sunwayworld.basemodule.rm.hospital.service.LimsInterfaceSourceService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsInterfaceSourceServiceImpl implements LimsInterfaceSourceService {

    @Autowired
    private LimsInterfaceSourceDao limsInterfaceSourceDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsInterfaceSourceDao getDao() {
        return limsInterfaceSourceDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsInterfaceSourceBean limsInterfaceSource = jsonWrapper.parseUnique(LimsInterfaceSourceBean.class);
        limsInterfaceSource.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsInterfaceSource);
        return limsInterfaceSource.getId();
    }


}
